#ifndef													__PLAYER_H_
# define												__PLAYER_H_

#include												<string>
#include												<cstdlib>
#include												<queue>
#include												<portaudio.h>
#include												"SoundPacket.h"
#include												<boost/thread/mutex.hpp>
#include												<boost/circular_buffer.hpp>
#include												"StreamCircularBuffer.h"
#include												<map>

class													Time;
class													Player
{
public:
	Player(Time &);
	~Player();

public:
	int													playCall(short *, unsigned long);
	void												play();
	void												stop();
	void												start();
	void												setVolume(float);
	void												newBuffer(unsigned int);
	void												destroyBuffer(unsigned int);
	SoundPacket											*getSoundPacket(unsigned int);
	void												packetReady(unsigned int);

private:
	Time												&_time;
	boost::mutex										_mutex;
	PaStream											*_stream;
	float												_volume;
	std::map<unsigned int, StreamCircularBuffer*>		_buffer;
	PaStreamParameters									_outputParameters;
	size_t												_sample_rate;
	size_t												_frames_per_buffer;
	size_t												_num_channels;
	int													_status;
	short												*_tmpBuf;
};

#endif // !__PLAYER_H__
